<template>
  <div>
    <TopFilter ref="topFilter" :list="topFilterList" :cols="3" labelWidth="110" @filterChange="changeHandle" @onCollapse="collapseHandle"></TopFilter>
    <FilterTable
      ref="table"
      height="auto"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :selectionType="'single'"
      :isSelectColumn="true"
      :onRowSelectChange="selectChange"
      :onColumnsChange="columns => this.columns = columns"
    >
    </FilterTable>
    <div class="dialogBottmView" >
      <el-button @click="closeDrawer(1)">关 闭</el-button>
      <el-button @click="closeDrawer(2)" type="primary">确 定</el-button>
    </div>
  </div>
</template>

<script>
  import { dictionary } from '@/utils/dictMixin';
  import { region } from '@/api/cms-common/region';
  import {getSortList} from '@/api/partsmanage/partinfos/partInfoManage/index';
  export default {
    mixins: [dictionary,region],
    name: 'partInfos',
    props: {
      rowData: {
        type: Object,
        default: () => ({})
      }
    },
    data() {
      this.saveData=null;
      return {
        topFilterList: this.createTopFilterList(),
        gethistroyList:[],
        columns: this.createTableColumns(),
        fetchParams: {
          sort: 2
        },
        fetchApi:getSortList,
        isSave:false,
        records:'',
        rowSelectData:[],//选中的配件
        saveLoading: false,
      };
    },
    created() {
    },
    methods: {
      changeHandle(val) {
        this.fetchParams = Object.assign({}, val);
        this.fetchParams.sort = 2
      },
      collapseHandle() {
        this.$nextTick(() => {
          this.BaseTable.EXECUTE_RESET_HEIGHT();
        });
      },
      createTopFilterList() {
        return[
          {
            type: 'INPUT2',
            label: '配件代码',
            fieldName: 'bjxmbh',
          },
          {
            type: 'INPUT',
            label: '配件名称',
            fieldName: 'bjzwmc',
          }
        ]
      },
      closeDrawer(type){
        if(type==1){
          this.$emit('close')
        }else{
          let params= this.rowSelectData
          this.$emit('close',params)
        }
      },
      selectChange(val) {
        this.rowSelectData = val;
      },
      createTableColumns () {
        return [
          {
            title: '序号',
            dataIndex: 'index',
            width: 70,
            sorter: true,
            render: props => {
              return <span>{props.row.index + 1}</span>;
            }
          },
          {
            title: '配件代码',
            dataIndex: 'bjxmbh',
            sorter: true,
          },
          {
            title: '配件名称',
            dataIndex: 'bjzwmc',
            sorter: true,
          },
          {
            title: '配件属性',
            dataIndex: 'bjpjsx',
            sorter: true,
            render: props => {    //编码转汉字
              return <span>{this.createDictText(props.row.bjpjsx, '5000')}</span>;
            }
          }
        ]
      },
    }
  };
</script>

<style scoped>

</style>
